package org.forex.impl.ws;

import java.io.IOException;
import java.util.HashMap;
import java.util.Optional;

import org.forex.impl.property.MainConfig;
import org.forex.vo.Instrument;

public class GetInstrumentsHistory extends AbstractHttpCallImpl<Instrument> {

	public GetInstrumentsHistory() {
		super(Instrument.class);
		parameters=new HashMap<String, String>();
		parameters.put("accountId", MainConfig.config().accountId());
		parameters.put("candleFormat", "midpoint");
	}

	public Optional<Instrument> get(Instrument instrument) throws IOException{
		parameters.put("instrument", instrument.getInstrument());
		return call("/v1/candles");
	}
	
	public Optional<Instrument> getNumResults(Instrument instrument,int count) throws IOException{
		parameters.put("instrument", instrument.getInstrument());
		parameters.put("count", ""+count);
		return call("/v1/candles");
	}

	@Override
	public String getHttpMethod() {
		return GET;
	}
}
